/* eslint-disable no-unused-vars */
import { getApi } from "@/api/api";
export default {
  namespaced: true,
  state: {
    id: 0,
    token: "",
    name: "",
    msgCount: 0
  },
  actions: {
    async updateMsgCount({ commit }, payload) {
      const [err, res] = await getApi("newsdetails").get("count");
      if (!err && res !== undefined) commit("updateMsgCount", res || "");
    }
  },
  mutations: {
    updateMsgCount(state, payload) {
      state.msgCount = payload;
    },
    updateId(state, id) {
      state.id = id;
    },
    updateName(state, name) {
      state.name = name;
    },
    setToken(state, token) {
      state.token = token;
    },
    setUser(state, { name, id, token }) {
      state.name = name;
      state.id = id;
      state.token = token;
    }
  }
};
